package me.helllp.book.concurrent.ch05;

/**
 * 演示Future模式
 * 
 * @author Administrator
 *
 */
public class FutureClient {
	public Data request(final String queryStr){
		final FutureData future = new FutureData();
		new Thread(){
			public void run() {
				RealData rd = new RealData(queryStr);
				future.setRealData(rd);
			};
		}.start();
		
		return future;
	}
	
	public static void main(String[] args) {
		FutureClient client = new FutureClient();
		
		Data data = client.request("lxm");
		System.out.println("已经请求完毕！");
		
		try {
			//	在创建RealData的时间内可以干别的！这里模拟一下
			Thread.sleep(2000);
		} catch (Exception e) {
			// TODO: handle exception
		}
		
		System.out.println("真实的数据为：" + data.getResult());
	}
}
